A switching power supply may generally include a main power converter and a controller. The controller in the switching power supply can connect to the main power converter, and the controller may output a switching control signal to control a main switch in the main power converter to be turned on or turned off, such that the switching power supply converts the input voltage into the voltage output required by the load. In order to prevent the power supply chip from being damaged due to a too high output voltage of the switching power supply, the controller may be provided with an output voltage detection circuit in order to achieve the output overvoltage protection for the switching power supply.